package com.wego.domain.enums;

import com.wego.bean.base.BaseEnum;
import com.wego.utils.EnumUtil;
import lombok.Getter;

@Getter
public enum UserGender implements BaseEnum {
    MALE(0, "女"),
    FEMALE(1, "男"),
    UNKNOWN(2, "保密");

    private Integer code;
    private String text;

    UserGender(Integer code, String text) {
        this.code = code;
        this.text = text;
    }

    /**
     * 根据code获取对应的枚举值
     * @param code 状态码
     * @return 对应的枚举值，如果未找到返回null
     */
    public static String getTextByCode(Integer code) {
        return EnumUtil.getTextByCode(UserGender.class, code);
    }

    /**
     * 根据text获取对应的枚举值
     * @param text 状态码
     * @return 对应的枚举值，如果未找到返回null
     */
    public static Integer getCodeByText(String text) {
        return EnumUtil.getCodeByText(UserGender.class, text);
    }

}
